package cn.sitedev.lazy;

/**
 * @author qchen
 * @description 静态内部类式单例
 * 优点: 写法优雅, 利用了Java本身的语法特点, 性能高, 避免了内存浪费
 * 缺点: 能够被反射破坏(之前的懒汉式, 饿汉式也都有这样的问题)
 * @date 2020/9/17 1:57
 */
public class Singleton4InnerClass {
    private Singleton4InnerClass() {

    }

    private static Singleton4InnerClass getInstance() {
        return LazyHolder.INSTANCE;
    }

    private static class LazyHolder {
        private static final Singleton4InnerClass INSTANCE = new Singleton4InnerClass();
    }


}
